package com.ssextjs.component;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.ssextjs.component.grid.ColumnModel;
import com.ssextjs.component.grid.GridPanel;
import com.ssextjs.engine.ConfiguraionImpl;
import com.ssextjs.engine.Layout;

public class Panel extends Component{
	
	public String baseCls="x-panel";
	public Component bbar=null;
	public boolean bodyBorder=true;
	public String bodyStyle="";
	public boolean border=true;
	public Button[] buttons={};
	public String cls="";
	public boolean collapseFirst=true;
	public boolean collapsed=false;
	public String collapsedCls="x-panel-collapsed";
	public boolean collapsible=false;
	public boolean disabled=false;
	public String disabledClass="x-item-disabled";
	public boolean draggable=false;
	public boolean frame=false;
	public int height;
	public boolean hidden=false;
	public String iconCls="";
	public String id="";
	public List<Component> items=new ArrayList();
	public int layout = Layout.BORDER;
	public String overCls="";
	public int pageX;
	public int pageY;
	public String style="";
	public String title=null;
	public int width=0;
	public int x;
	public int y;
	public Component tbar = null;
	public String html=null;
	
	public Panel() {
	}
	
	public Panel(Map opt) {
		setMapOpt(opt);
		tplInit();
	}
	
	public Panel setLayout(int lay) {
		this.layout = lay;
		return this;
	}
	public int getLayout() {
		return this.layout;
	}
	
	public Panel setTbar(Toolbar tbar) {
		if (this.title.isEmpty()) {
			tbar.noHeader(true);
		}else{
			tbar.noHeader(false);
		}
		this.tbar=tbar;
		return this;
	}
	
	public Component getTbar() {
		return this.tbar;
	}
	
	public Panel setBbar(Component bbar) {
		this.bbar=bbar;
		return this;
	}
	
	public Component getBbar() {
		return this.bbar;
	}
	
	public void tplInit() {
		try {
			tpl = ConfiguraionImpl.getCfg().getTemplate("Panel.tpl");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public Panel addButton(Button btn) {
		this.buttons[this.buttons.length]=btn;
		return this;
	}
	
	public Panel addItem(Component it) {
		this.items.add(it);
		return  this;
	}
	
	public Panel setHTML(String html) {
		this.html=html;
		return this;
	}
	
	public String getBaseCls() {
		return baseCls;
	}

	public Panel setBaseCls(String baseCls) {
		this.baseCls = baseCls;
		return this;
	}
	
	public String getStyle() {
		return style;
	}

	public Panel setStyle(String style) {
		this.style = style;
		return this;
	}

	public boolean isBodyBorder() {
		return bodyBorder;
	}

	public Panel setBodyBorder(boolean bodyBorder) {
		this.bodyBorder = bodyBorder;
		return this;
	}

	public String getBodyStyle() {
		return bodyStyle;
	}

	public Panel setBodyStyle(String bodyStyle) {
		this.bodyStyle = bodyStyle;
		return this;
	}

	public boolean isBorder() {
		return border;
	}

	public Panel setBorder(boolean border) {
		this.border = border;
		return this;
	}

	public String getCls() {
		return cls;
	}

	public Panel setCls(String cls) {
		this.cls = cls;
		return this;
	}

	public boolean isCollapseFirst() {
		return collapseFirst;
	}

	public Panel setCollapseFirst(boolean collapseFirst) {
		this.collapseFirst = collapseFirst;
		return this;
	}

	public boolean isCollapsed() {
		return collapsed;
	}

	public Panel setCollapsed(boolean collapsed) {
		this.collapsed = collapsed;
		return this;
	}

	public String getCollapsedCls() {
		return collapsedCls;
	}

	public Panel setCollapsedCls(String collapsedCls) {
		this.collapsedCls = collapsedCls;
		return this;
	}

	public boolean isCollapsible() {
		return collapsible;
	}

	public Panel setCollapsible(boolean collapsible) {
		this.collapsible = collapsible;
		return this;
	}

	public boolean isDisabled() {
		return disabled;
	}

	public Panel setDisabled(boolean disabled) {
		this.disabled = disabled;
		return this;
	}

	public String getDisabledClass() {
		return disabledClass;
	}

	public Panel setDisabledClass(String disabledClass) {
		this.disabledClass = disabledClass;
		return this;
	}

	public boolean isDraggable() {
		return draggable;
	}

	public Panel setDraggable(boolean draggable) {
		this.draggable = draggable;
		return this;
	}

	public boolean isFrame() {
		return frame;
	}

	public Panel setFrame(boolean frame) {
		this.frame = frame;
		return this;
	}

	public int getHeight() {
		return height;
	}

	public Panel setHeight(int height) {
		this.height = height;
		return this;
	}

	public boolean isHidden() {
		return hidden;
	}

	public Panel setHidden(boolean hidden) {
		this.hidden = hidden;
		return this;
	}

	public String getIconCls() {
		return iconCls;
	}

	public Panel setIconCls(String iconCls) {
		this.iconCls = iconCls;
		return this;
	}

	public String getId() {
		return id;
	}

	public Panel setId(String id) {
		this.id = id;
		return this;
	}

	public List<Component> getItems() {
		return items;
	}

	public Panel setItems(List<Component> items) {
		this.items = items;
		return this;
	}

	public String getOverCls() {
		return overCls;
	}

	public Panel setOverCls(String overCls) {
		this.overCls = overCls;
		return this;
	}

	public int getPageX() {
		return pageX;
	}

	public Panel setPageX(int pageX) {
		this.pageX = pageX;
		return this;
	}

	public int getPageY() {
		return pageY;
	}

	public Panel setPageY(int pageY) {
		this.pageY = pageY;
		return this;
	}

	public String getTitle() {
		return title;
	}

	public Panel setTitle(String title) {
		this.title = title;
		return this;
	}

	public int getWidth() {
		return width;
	}

	public Panel setWidth(int width) {
		this.width = width;
		return this;
	}

	public int getX() {
		return x;
	}

	public Panel setX(int x) {
		this.x = x;
		return this;
	}

	public int getY() {
		return y;
	}

	public Panel setY(int y) {
		this.y = y;
		return this;
	}
	
	
	// Grid
	public Panel setForceFit(boolean fl) {
		return this;
	}
	
	public boolean getForceFit() {
		return false;
	}
	
	public Panel setStripeRows(boolean fl) {
		return this;
	}
	
	public boolean getStripeRows() {
		return false;
	}
	
	public Panel setColumnModel(ColumnModel cm) {
		return this;
	}
	public ColumnModel getColumnModel() {
		return null;
	}
}
